package org.example.split;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class SplitDemo {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(2);
        DataStreamSource<String> source = env.socketTextStream("localhost", 9999);

        source.filter(value -> Integer.parseInt(value) % 2 == 0).print("偶数流");
        source.filter(value -> Integer.parseInt(value) % 2 == 1).print("奇数流");

        env.execute("PartitionDemo");
    }
}
